#
# @lc app=leetcode.cn id=693 lang=python
#
# [693] 交替位二进制数
#

# @lc code=start
class Solution(object):
    def hasAlternatingBits(self, n):
        """
        :type n: int
        :rtype: bool
        """
        # bin_n = bin(n)[2:]
        # for i in range(len(bin_n)-1):
        #     if bin_n[i] == bin_n[i+1]:
        #         return False
        # return True
        # m=(n ^ (n >> 1))
        # return  m & m+1 == 0
        return "11" not in bin(n) and "00" not in bin(n)
# @lc code=end

